
export default {
    data() {
        return {
            pageName: '',
            editList: [],
            rules: {}
        };
    },

    methods: {
        close() {
            this.$refs.edit.resetFields();
            this.$store.dispatch(`${this.pageName}/cancelEdit`);
        },
        submit() {
            this.$refs.edit.validate((valid) => {
                if (valid) {
                    let options = {};
                    if (this.editData.editType !== 'add') {
                        options.id = this.editData.editRow.id;
                    }
                    console.log(this.editList);
                    this.editList.forEach(key => {
                        options[key] = this.editData.editRow[key] || '';
                    })
                    this.$store.dispatch(`${this.pageName}/save`, options);
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        }
    }
};